package com.mediacloud.app.newsmodule.fragment.microlive;

import com.mediacloud.app.newsmodule.adaptor.NewsListItemStyleAdaptor;
import com.mediacloud.app.newsmodule.adaptor.bigimg_nosliceline.BigImageNoSliceLineAdaptor;
import com.mediacloud.app.newsmodule.adaptor.microlive.MicroLiveListAdapter;
import com.mediacloud.app.newsmodule.fragment.BaseNewsListFragment;
import com.mediacloud.app.newsmodule.utils.BindEventBus;
import com.mediacloud.app.reslib.enums.StyleOther;

/**
 * 微直播
 */

public class MicroLiveListFragment extends BaseNewsListFragment
{
    @Override
    public void initView()
    {
        super.initView();

        if (adaptor instanceof NewsListItemStyleAdaptor) {
            ((NewsListItemStyleAdaptor) adaptor).destroy();
        }
        if (adaptor instanceof BigImageNoSliceLineAdaptor){
            ((BigImageNoSliceLineAdaptor) adaptor).destroy();
        }
        //如果有其他样式的 就用这个列表样式了
        if(catalogItem.getCatalogStyle()== StyleOther.OtherStyle)//&&catalogItem.getStyleOther()!=null)
        {
            adaptor=new BigImageNoSliceLineAdaptor(getActivity(),catalogItem,null);
        }else{
            adaptor=new MicroLiveListAdapter(getActivity(), catalogItem ,true);
        }
        mCatalogContentItemListView.setAdapter(adaptor);
        new  BindEventBus(this,adaptor);
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (adaptor instanceof MicroLiveListAdapter){
            ((MicroLiveListAdapter) adaptor).clearEvent();
            ((MicroLiveListAdapter) adaptor).clearSpiderObservers();
        }
    }
}